package com.qidian.common.pojo;


import com.qidian.common.util.Constant;

/**
 * @Author 戴着假发的程序员
 * @Company 起点编程
 * @Description
 * @Time 2024/9/4 下午 2:42
 */
public class MESResult {
    private Integer code;
    private String msg;
    private Object data;

    public MESResult() {
    }

    // 为了方便获取这个类对象，我们添加一些获取这类对象的方法
    public MESResult(Integer code, String msg, Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    // 静态方法获取
    public static MESResult success(){
        return new MESResult(Constant.RESPONSE_STATUS_OK,"OK",null);
    }
    public static MESResult success(Integer code){
        return new MESResult(code,"OK",null);
    }
    public static MESResult success(Integer code, String msg){
        return new MESResult(code,msg,null);
    }
    public static MESResult success(Object data){
        return new MESResult(Constant.RESPONSE_STATUS_OK,"OK",data);
    }
    public static MESResult success(Integer code, String msg, Object data){
        return new MESResult(code,msg,data);
    }

    public static MESResult error(){
        return new MESResult(Constant.RESPONSE_STATUS_ERROR,"ERROR",null);
    }
    public static MESResult error(Integer code){
        return new MESResult(code,"ERROR",null);
    }
    public static MESResult error(Integer code, String msg){
        return new MESResult(code,msg,null);
    }
    public static MESResult error( String msg){
        return new MESResult(Constant.RESPONSE_STATUS_ERROR,msg,null);
    }
    public static MESResult error(Object data){
        return new MESResult(Constant.RESPONSE_STATUS_ERROR,"NO",data);
    }

    public static MESResult isSuccess(int i) {
        return i == 1?success():error();
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
